package com.stx.servlet.visitor;

import com.stx.bean.Car;
import com.stx.bean.Visitor;
import com.stx.mapper.VisitorMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
/*更新访客数据*/
@WebServlet(urlPatterns = {"/visitorUpdate"})
public class VisitorUpdateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        String name = req.getParameter("name");
        String visiteWho = req.getParameter("visiteWho");
        String phone = req.getParameter("phone");
        String idCard = req.getParameter("idCard");
        String date = req.getParameter("visiteTime");
        Visitor visitor = new Visitor(id, name, visiteWho, phone, idCard, date);

        try {
            VisitorMapper.visitorUpdate(visitor);
            resp.sendRedirect("/visitorList");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

}
